﻿using Easy.Common;
using Easy.Domain.Core;
using Easy.Domain.Test.Models;
using Easy.Domain.Test.Models.Mapping;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Easy.Common.RegisterType;

namespace Easy.Domain.Test
{
    [RegisterType(typeof(TestUnitOfWork))]
    public interface ITestUnitOfWork : IUnitOfWork
    {

    }

    [RegisterType(typeof(TestUnitOfWork), InterceptorType.VirtualMethod)]
    public class TestUnitOfWork : UnitOfWork, ITestUnitOfWork
    {
        public TestUnitOfWork()
            : base("Name=EFTestContext")
        {
            this.Configuration.AutoDetectChangesEnabled = true;
        }

        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }
        public DbSet<VBlog> VBlogs { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new BlogMap());
            modelBuilder.Configurations.Add(new PostMap());
            modelBuilder.Configurations.Add(new VBlogMap());
        }
    }
}
